<%
# 
# Copyright (C) 2006  Warren Konkel and Bounty Source, Inc.
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
# 
%>


<ul>
	<%= render :partial => 'repositories/repository', :locals => { :repository => @repostiroy } %>
</ul>

<div style="float:left;">

	<strong><%= @sub_title%>:</strong>
  <a href="<%=$bs_svn_browser[:url_base]%>/!tree/<%=@rev%>">Revision <%=@rev%></a>
  <%
    if @info[:file?]
      header_path = @path[0..-2]
      header_file = @path[-1]
    else
      header_path = @path
      header_file = nil
    end
    path_history = []

    header_path.each { |p|
      path_history << p
      %> / <a href="<%=$bs_svn_browser[:url_base]%>/!tree/<%=@rev%>/<%=File.join(path_history)%>"><%=p%></a> <%
    }

    if header_file
      path_history << header_file
      %> / <a href="<%=$bs_svn_browser[:url_base]%>/!source/<%=@rev%>/<%=File.join(path_history)%>"><%=header_file%></a> <%
    end
  %>
</div>

<div style="background: white; text-align: right; padding: 0; border: 0px none #aaa; float: right;">
  <form method="post" action="<%=$bs_svn_browser[:url_base]%>/!form/<%=@rev%>/<%=File.join(@path)%>">

    Show me the 

    <select name="formact" id="action" onchange="updateFormFields()">
      <option value="tree" <%='selected="selected"' if params[:action] == 'tree'%>>revision tree</option>
      <option value="source" <%='selected="selected"' if params[:action] == 'source'%>>source</option>
      <% if !@info[:binary?] %>
        <option value="blame" <%='selected="selected"' if params[:action] == 'blame'%>>blame</option>
      <% end %>
      <option value="history" <%='selected="selected"' if params[:action] == 'history'%>>history</option>
      <% if @info[:file?] %>
        <option value="revdiff" <%='selected="selected"' if params[:action] == 'revdiff'%>>revision differences</option>
      <% end %>
      <option value="pathdiff" <%='selected="selected"' if params[:action] == 'diff'%>>path differences</option>
    </select>

    <span id="for_revision">
      for revision <input name="revision" type="text" size="5" value="<%=@rev%>" />
    </span>

    <span id="src1" style="display: none">
      of <input type="text" name="src1_path" value="/<%=File.join(@path)%>" />
      at revision <input type="text" name="src1_revision" size="5" value="<%=@rev%>" />
    </span>

    <span id="revstop" style="display: none">
      stopping at revision <input type="text" name="stop_revision" size="5" value="<%=params[:stop_revision] || '0'%>" />
    </span>
    

    <span id="src2" style="display: none">
      against <input type="text" name="src2_path" value="<%=params[:against_path] || "/#{File.join(@path)}"%>" />
      at revision <input type="text" name="src2_revision" size="5" value="<%=params[:against_rev] || @rev%>" />
    </span>

    <% if @info[:file?] %>
      <span id="prev_diff" style="display: none">
        between
        <select name="prev_revision1" id="revision">
          <% for revision in @revisions %>
            <option <%='selected="selected"' if params['rev1'].to_i == revision[:revision]%> value="<%=revision[:revision]%>"><%=revision[:revision]%> (<%=time_ago_in_words(revision[:date])%> ago by <%=revision[:author]%>)</option>
          <% end %>
        </select>
        and
        <select name="prev_revision2" id="revision">
          <% for revision in @revisions %>
            <option <%='selected="selected"' if params['rev2'].to_i == revision[:revision]%>  value="<%=revision[:revision]%>"><%=revision[:revision]%> (<%=time_ago_in_words(revision[:date])%> ago by <%=revision[:author]%>)</option>
          <% end %>
        </select>
      </span>
    <% end %>

    <input type="submit" value="Go!" />
  </form>
</div>

<script type="text/javascript">
<!--
  // make sure everything is properly shown/hidden
  updateFormFields()
-->
</script>
